1 Terminal Emulation ------------------ What is Emulation? ------------------ The emulation feature allows you to let your personal computer act like, or emulate, a terminal such as the DEC VT-100, the IBM 3101, or the Wyse 50. For example, if a certain sequence received from the host computer instructs a terminal to clear the screen, the emulation feature will tell BitCom to clear the screen when that same sequence is received. If the host computer that you are connected to uses full screen applications such as an accounting system or editor, you may need to use the terminal emulation feature. Most other systems such as CompuServe or Easylink display text line by line. These types of systems do not need to use emulation. If you are not sure whether emulation is needed or not, check with the company or department running the host computer. Generally, you should not use emulation unless you are specifically instructed to emulate a particular terminal. An exception to this is many BBS's that use ANSI color/graphics. If you have a graphics monitor and want to take advantage of this, use the ANSI emulation file. BitCom's emulation files are programmable. This means you can change many options, keys or colors by editing a file called the emulation file. The emulation file tells BitCom what keys to use, what characters to filter, and how to enable certain functions. The emulation file is a text (ASCII) file, so you can edit or change it using any text editor. Included on the BitCom diskette are the following emulation files. ANSI.EMU for ANSI color/graphics support VT100A.EMU for DEC VT-100 with ANSI support VT100B.EMU for DEC VT-100 with ANSI and VT-52 support 3101.EMU for IBM 3101 terminal WYSE50.EMU for Wyse 50 terminal WYSE60.EMU for Wyse 60 terminal TVI920.EMU for Televideo 920 terminal TVI9XX.EMU for Televideo 900 series terminals Keyboard mapping for these terminals is shown at the end of this section. 2 Using Terminal Emulation ------------------------ To set up a phone number record to use terminal emulation, follow the steps below. 1. From the Communications Selection Menu, press the up or down arrow keys until the pointer is next to the record requiring terminal emulation. 2. Press 'S' to Show More. This will take you to the Communications Parameters Menu. 3. Highlight the 'Emulation' field' by pressing the up or down arrow keys. 4. Type in the emulation file name, without the .EMU filename extension. For example, to use the VT100A.EMU file, you would type in VT100A. 5. If you are using an emulation file such as ANSI that supports color/graphics, set the 'Input' and 'Output' fields to No. To do this, press the up or down arrow keys until the appropriate field is highlighted, then the right or left arrow keys until 'No' is displayed in the field. 6. If you are using an emulation file other than ANSI, you also need to change the BitCom special keys that will conflict with the function keys defined in the emulation file. If you need to do this follow steps 7 through 10. If you do not need to do this, jump to step 11. 7. Press the up or down arrow keys until the first special key (Help) is highlighted. 8. Press . 9. Press the new key value. You might want to use Alt-F1 or Shift-F1. 10. Repeat steps 7 through 10 for the Escape, Print, and Snapshot keys. 11. Press . This will take you back to the Communications Selection Menu. 12. When you connect with your host computer using this record, the emulation file will be invoked automatically. Your keyboard will simulate the appropriate terminal that you have chosen to emulate. 3 How Terminal Emulation Works ---------------------------- Terminal emulation usually involves translating the commands that are sent to and from the host computer, to the functions that are defined by the terminal manufacturers. These commands usually, but not always, start with the ASCII code ESC (hexadecimal 1B), followed by a sequence of characters. Therefore, this sequence is commonly known as an escape sequence. The escape sequence definitions are different from terminal to terminal. For example, the DEC VT-100 uses a different escape sequence than the IBM 3101. If you need more information about particular escape sequences, consult the terminal manufacturer's hardware reference manual. Some terminals, such as the Televideo and the Wyse, use control codes in addition to escape sequences. Control codes are displayed in an emulation file as a hexadecimal number, preceded by a dollar sign ( $ ). If you are not familiar with programming concepts, we suggest that you do not attempt to modify existing emulation files by yourself. Common Problems Using Terminal Emulation ---------------------------------------- When using terminal emulation, you may sometimes experience one of the following problems. **Problem** When using emulation, the function keys do not work for the application that is being used. For instance, instead of acting like the Gold Key on a VT-100, it brings up the BitCom Help Screen when pressed. **Solution** The BitCom special keys are conflicting with the function keys that are defined in the emulation file. Normally, BitCom will use F1 through F5. Change the BitCom special keys on the Communications Parameters Menu for the record that is using emulation. You may want to use Alt-F1 through Alt-F5, or Shift-F1 through Shift-F5. **Problem** The screen displays a set of strange characters beginning with a small left arrow when using a full screen application program (e.g. data entry). 4 **Solution** The escape sequence that is appearing on your screen is not defined in the emulation file. Find out from the terminal manufacturer what this sequence should do, and then edit the emulation file to correctly define this sequence. You can use any text editor to edit an emulation file. **Problem** A graphics type character appears on the screen that is not defined in the emulation file. **Solution** If the character does not begin with a left arrow (Escape), it may be a control character that is being sent by the host. You may want to check with the systems operator of the host system to see if it can be filtered out. To filter out the character, you would change it to a null character in the INBUFFER section of the emulation file. For example, to filter out the hexadecimal characters of 1C and 1D, add the following two lines to the INBUFFER section of your file. 0x1C NUL 0x1D NUL Emulation File Format --------------------- An emulation file consists of several sections. Each of these sections must be present in an emulation file (even if they are empty), and they must be in the following order. INITIAL The initialization section INBUFFER Definition of input buffer translations INBUFFER2 Definition of secondary input buffer (if any) OUTBUFFER Definition of output translations HOSTCODE Definition of received escape sequences Each of these sections must begin with the keyword above shown on a line by itself. It would be followed by appropriate commands (if any), and they would be followed by the keyword 'END' on a line by itself. You can include remarks in an emulation file within braces ({,}). All comments must begin and end on the same line. You should not have any blank lines in an emulation file. 5 Emulation File Commands ----------------------- Emulation files can use most script and action file commands. In addition, there are emulation file commands that can only be used in emulation files. These commands are explained below. Cursor Movement --------------- z#Curup(n,x) Moves the cursor up 'n' lines. x=1 means to scroll to the top. z#Curdn(n,x) Moves the cursor down 'n' lines. x=1 means to scroll to the bottom z#Curfwd(n) Moves the cursor to the right 'n' columns. z#Curbak Moves the cursor to the left 'n' columns. Save Environment ---------------- z#Savpos Save the current cursor position and attributes. z#Respos Restore cursor position and attributes (saved with z#Savpos). z#Savorg Save current origin flag. z#Resorg Restore origin flag (saved with z#Savorg). z#Savbuf Save current buffer settings. z#Resbuf Restore buffer settings (saved with z#Savbuf). 6 Global Flags ------------ z#Setatt(n) Set current attributes. Typical values for 'n' are: 07 Normal 112 Reverse video 02 Green or normal 14 Bold or bright yellow 01 Underscore or blue 128 Blinking z#Setbuf(n,m) n=1 means SI will enable first input buffer. n=2 means SI will enable second input buffer. n=3 means SO will enable first input buffer. n=4 means SO will enable second input buffer. m=1 means active character set is changed immediately as if a SI character had been received. z#Origin(n) Sets flag so cursor positions are taken to be relative to scroll window (n=2); or absolute (n=1). z#Awrap(n) Sets flag so characters displayed beyond end of the screen will wrap (n=0); will not wrap (n=1); will be truncated (n=2); or will wrap characters and cursor movement (n=3). z#Setmar(r1,r2) Sets scroll window rows (r1) through (r2). z#Scroll(n) Sets the scrolling in Wyse emulation when last character is at line 24, row 80. If n=0, will cause cursor to move to column 1, row 1. If n=1, will cause screen to scroll up one line when a new character is received. z#Lfnl(n) Sets flag so that line feeds are treated like a new line (n=1) or not (n=2). z#Setenq(s) Sets message to be sent when an ENQ character is received. z#Setflg(1,n) Sets a flag to 'n' (a number). '1' is a single character in the range 'a' to 'z'. z#Flg(1) Returns the value of a given flag. z#Setins(n) n=0 sets replace mode; n=1 sets insert mode. 7 Screen Clear ------------ z#Clreol Clear from cursor to end of the line. z#Clrbol Clear from the beginning of the line to the cursor position. z#Clrlin Clear the line containing the cursor. z#Clreos Clear from the cursor to the end of the screen. z#Clrbos Clear from the beginning of the screen to the cursor position. Tab Settings ------------ z#Tabset Set tab at current cursor column. z#Tabclr Clear tab at current cursor column. z#Tabcla Clear all tab settings. Miscellaneous ------------- z#inslin(n) Insert 'n' number of lines at cursor line. z#Dellin(n) Delete 'n' number of lines at cursor line. z#Del(n) Deletes character at the cursor position, and shifts the line one position to the left. z#Chr(n) Converts 'n' to a single character and writes it to the port. Mnemonics Used -------------- In addition to the functions shown above, there are certain mnemonics used by BitCom emulation files. These are normally used in the INBUFFER, INBUFFER2, and OUTBUFFER sections. 8 Mnemonic Action Taken -------- ------------ ESC Begins an escape sequence BEL Speaker beeps HT Horizontal tab LF Line feed BS Destructive backspace BS2 Non-destructive backspace FF Clears screen CR Carriage return DC1 XON character DC3 XOFF character CAN Cancels escape sequence if one is being received NUL Ignores on input SI Switch active buffer to G0 (defined by z#Setbuf) SO Switch active buffer to GI (defined by z#Setbuf) ENQ Transmits string defined by z#Setenq(s) The INITIAL Section ------------------- This section of an emulation file consists of statements. The statements may assign built-in variables, assign functions to special keys, or assign start up commands. For instance, you may want to begin the session in the insert mode. In this section, you would have the statement: z#Setins(1) To assign a function or string to a key, the statements might be similar to the following: @Alt-I='z#Setins(1) {turns on insert mode}' @Alt-S='"ABC" {sends the string ABC}' The INBUFFER Section -------------------- The 'input buffer' defines translations that take place when a character is read from the host port to your PC. This is useful if you want a character that the host sends to have a different meaning than BitCom would normally apply to it. 9 For example, when BitCom receives a form feed (FF) character, it will normally clear the screen. However, some terminals treat a form feed character as if it were a line feed character (LF). To define this translation, you would use a line such as: 0x0C LF The format of translations in this section is: the hexadecimal representation of the number to be translated, followed by: 1) a special mnemonic, such as LF, or 2) another hexadecimal number (e.g. 0x1F). The mnemonics which are understood by BitCom are defined earlier in this chapter, along with the actions that they will perform. When you begin communications, the input buffer is initialized in a manner such that no translation will take place. The INBUFFER2 Section --------------------- This section has the same format as the INBUFFER section, but defines a secondary input buffer. Some terminals have a second buffer which interprets characters differently (e.g. a special graphics symbol set). Two input buffers are sometimes needed. For instance, with DEC computers, the second buffer is used for graphic or foreign symbols, and the first buffer is only used for text. The OUTBUFFER Section --------------------- This section uses the same format as the INBUFFER and INBUFFER2 sections, but defines characters being sent from your PC to the host. It is used to translate a character that is sent to the host computer into a different character. The HOSTCODE Section -------------------- This section defines escape sequences that are received from the host computer. The first token on a line in this section defines the escape code. A token is each separate part of a statement. The code may not contain blanks, unless the blank is preceded by a backslash character ( \ ). The escape sequence should NOT contain the Escape character in this definition, since it is assumed. 10 If you are defining a control code that does not begin with Escape, the first token should be the hexadecimal representation of the control code, such as $05 for a Control-E. If the second token is blank, the first token will be translated to a null. In the VT100A.EMU file, the code Esc[5h should set the attributes to blinking. The line in the HOSTCODE section that performs this translation is: [5h z#Setatt(112) Lines in this section can also contain the special sequence '\\c' (where 'c' is the same character as used in the first token). This sequence will be replaced with the number found when the pattern is matched. Shown below are two examples. Pattern Action ------- ------ [\g;\cf poscur(\\c,\\g) [6n "$1b[@row;@col.R" If the sequence "Esc[20;30f" were received, this function "poscur(30,20)" would be invoked. If the sequence "Esc[6n" were received, the string "Esc[20;30R" would be transmitted to the host computer. Note that the built-in variables @Col and @Row are used for this. There may also be a percent sign ( % ) followed by a letter in the pattern and action. In this case, the pattern means a single character will be in this position, and the "%C" in the action will be replaced by the numeric value of the character that is found. Emulation Keyboard Assignments ------------------------------ Included on your program diskette are the emulation files VT100A, VT100B, 3101, WYSE50, TVI920, and TVI9XX. For these files, the key assignments for your computer are as follows: 11 VT-100 Emulation ---------------- VT100 Keys IBM PC Keys ---------- ----------- PF1 - PF4 F1 - F4 PF6 - PF10 F6 - F10 (VT100A only) Arrow Keys Arrow Keys Delete Del App-0 to App-9 NL-0 to NL-9 (VT100B only) App - Alt - App_ Alt = App ENTER Alt + Arrow Keys Arrow Keys IBM 3101 Emulation ------------------ IBM 3101 Keys IBM PC Keys ------------- ----------- PF1 to PF8 F1 to F8 Clear Screen Alt-C Erase Input Alt-I Erase EOL Alt-E Erase EOS Alt-S Home Cursor Home Arrow Keys Arrow Keys 12 Wyse 50 Emulation ----------------- Wyse 50 Keys IBM PC Keys ------------ ----------- Arrow Keys Arrow Keys Insert Character Ins Delete Character Del Line Erase End Home Cursor Home Reverse Tab Shift Tab Insert Line Control-Home Page Erase Control-End Delete Line Control-PgUp Clear Screen Control-PgDn F1 - F10 F1 - F10 F11 Shift-F1 Shift Line Erase Shift-F3 Shift Page Erase Shift-F4 Shift Line Insert Shift-F5 Shift Line Delete Shift-F6 Shift Char Insert Shift-F7 Shift Char Delete Shift-F8 Televideo Emulation ------------------- Televideo Keys IBM PC Keys -------------- ----------- Arrow Keys Arrow Keys Page PgUp Shift-Page PgDn Home Home Insert Char Insert Delete Char Delete Line Erase End Insert Line Control-Home Page Erase Control-End Delete Line Control-PgUp Clear Screen Control-PgDn Reverse Tab Shift-Tab F1 - F10 F1 - F10 F11 Shift-F1 Shift Line Erase Shift-F3 Shift Page Erase Shift-F4 Shift Line Insert Shift-F5 Shift Line Delete Shift-F6 Shift Char Insert Shift-F7 Shift Char Delete Shift-F8